package com.haois.ws.common.Interceptor.configuration;

import com.haois.ws.common.Interceptor.ManagerInterceptor;
import com.haois.ws.web.module.rbac.service.ManagerService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * Created by haol on 2017/4/1.
 */
@Configuration
public class InterceptorConfiguration extends WebMvcConfigurerAdapter {
    @Autowired
    private ManagerService managerService;

    public void addInterceptors(InterceptorRegistry registry) {
        InterceptorRegistration interceptorRegistry = registry.addInterceptor(
                new ManagerInterceptor(managerService));
        interceptorRegistry.addPathPatterns("/api/web/**");
        interceptorRegistry.excludePathPatterns("/api/web/log/**");
        interceptorRegistry.excludePathPatterns("/api/web/url/list/**");
        interceptorRegistry.excludePathPatterns("/api/web/email/**");
    }
}
